﻿<UserControl x:Class="SQLServerOptimizer.PL.WPF.IssueSettings"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:sys="clr-namespace:System;assembly=mscorlib"
                Name="IssueSetting"
         Width="Auto" Height="Auto" 
                 xmlns:local="clr-namespace:SQLServerOptimizer.PL.WPF"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"       >
<!-- Loaded="UserControl_Loaded" -->


    <UserControl.Resources>
        <ControlTemplate x:Key="ImageButtonTemplate" TargetType="{x:Type ToggleButton}">
            <Image x:Name="Image1" Source="Expanderplus.png"/>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter TargetName="Image1" Property="Source" Value="Expander.png"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <DataTemplate x:Key="settingstemp" DataType="issuestypes" >


            <DockPanel LastChildFill="True" Width="Auto" HorizontalAlignment="Stretch"  >
                <DockPanel.Resources>

                    <Style TargetType="{x:Type ToggleButton}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ThresholdValues.Count}" Value="0">
                                <Setter Property = "Visibility" Value="Hidden"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DockPanel.Resources>

                <DockPanel Width="Auto" HorizontalAlignment="Stretch" LastChildFill="True">


                
                    <StackPanel DockPanel.Dock="Bottom" x:Name="threshold" Visibility="Collapsed" >
                        <ListBox ItemsSource="{Binding ThresholdValues}" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Tag="{Binding IssueTypeID}"  >

                                        <TextBlock  Text="{Binding ThresholdDescription}"/>
                                        <TextBox Padding="0,0,0,5" Text="{Binding Value}"  Tag="{Binding ThresholdValueID}" TextChanged="TextBox_TextChanged" />
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>

                    </StackPanel>
					    <DockPanel Tag="{Binding IssueTypeId}" Width="Auto" DockPanel.Dock="Top" LastChildFill="true">
                      
					    <DockPanel.Resources>
					    
                            <Style TargetType="DockPanel"></Style>
                        </DockPanel.Resources>
                        <ToggleButton x:Name="tbtn" Padding="5" Template="{StaticResource ImageButtonTemplate}" Height="15" Width="15" VerticalAlignment="Top" Click="Button_Click"/>
                        <CheckBox  Padding="5"  IsChecked="{Binding Enabled}" Checked="CheckBoxenable_Checked" Unchecked="CheckBoxenable_Unchecked" />
                        <TextBlock   Padding="5,0,5,5" Text="{Binding Description}" TextWrapping="Wrap" MaxWidth="400" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" />


                        <ComboBox x:Name="cbtest" DockPanel.Dock="Right" Padding="5" Width="70" Height="Auto" VerticalAlignment="Top" SelectionChanged="cbtest_SelectionChanged" HorizontalContentAlignment="Stretch" HorizontalAlignment="Right">
                            <ComboBox.Style>
                                <Style TargetType="{x:Type ComboBox}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Severity}" Value="3">
                                            <Setter Property="SelectedIndex" Value="2" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Severity}" Value="2">
                                            <Setter Property="SelectedIndex" Value="1" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Severity}" Value="1">
                                            <Setter Property="SelectedIndex" Value="0" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ComboBox.Style>
                            <ComboBoxItem  x:Name="Low" Content="Low"/>
                            <ComboBoxItem x:Name="Med" Content="Med"/>
                            <ComboBoxItem x:Name="High" Content="High"/>
                        </ComboBox>
                    </DockPanel>
                </DockPanel>
            </DockPanel>
        </DataTemplate>

    </UserControl.Resources>
    <DockPanel  LastChildFill="True" >
        <ListBox VirtualizingStackPanel.IsVirtualizing="False" ItemTemplate="{StaticResource settingstemp}"   x:Name="testbox"  DockPanel.Dock="Top" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" Padding="0" VerticalContentAlignment="Stretch" BorderThickness="0">
            <ListBox.Resources>
                <Style TargetType="ListBox" />

            </ListBox.Resources>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    </DockPanel>


</UserControl>
